#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 27 12:32:33 2018

@author: zhuo
"""

import matplotlib.pyplot as plt
import numpy as np
data1 = [[],[]]
data2 = [[],[]]
Nuclei = "O16"
Type = "IVD"
path_1 = "../../data/nnlosat2b/"
path_2 = "../../data/nnlosat2b_3b/"
end = ".txt"
filename1 = path_1+Nuclei+"_sat2b_12_"+Type+end
filename2 = path_2+Nuclei+"_"+Type+end
with open(filename1) as f:
      for line in f.readlines()[1:]:
            for each in enumerate(line.split()):
                  #print ("each[0]", each[0], "\t each[1]", each[1])
                  data1[each[0]].append(float(each[1]))
x1,y1 = data1
with open(filename2) as f:
      for line in f.readlines()[1:]:
            for each in enumerate(line.split()):
                  #print ("each[0]", each[0], "\t each[1]", each[1])
                  data2[each[0]].append(float(each[1]))
x2,y2 = data2

y1_max = max(y1)
y2_max = max(y2)
y_max = max(y1_max,y2_max)
ylim_max = y_max*1.1

x1_max = max(x1)
x2_max = max(x2)
x_max = max(x1_max,x2_max)
xlim_max = x_max*1

plt.figure()
plt.plot(x1, y1, label='$nnlo_{sat}\quad 2N$')
plt.plot(x2, y2, label='$nnlo_{sat}\quad 2N+3N$')
plt.legend(loc='upper right')

plt.ylim(0,ylim_max)
plt.xlim(0,xlim_max)
plt.xlabel('$E[MeV]$',fontsize=16)
plt.ylabel('$R$',fontsize=16)
font_dict = {'family':'serif','color':'darkred','size':18}

plt.text(0.8*x_max, 0.7*y_max,Nuclei,fontdict=font_dict)
plt.text(0.8*x_max, 0.6*y_max,Type,fontdict=font_dict)
output=Nuclei+"_"+Type+".jpg"
plt.savefig(output,dpi = 200)
plt.show()